/*

 * 实现一种算法，找出单向链表中倒数第 k 个节点。返回该节点的值
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };

 */
int kthToLast(struct ListNode* head, int k) 
{
    struct ListNode* fast,*slow;
    fast=slow=head;
    while(k--)
    {
        fast=fast->next;
    }
    while(fast)
    {
        fast=fast->next;
        slow=slow->next;
    }

        return slow->val;

}